<!DOCTYPE html>
<!--把html 的名称空间，改成：xmlns:th="http://www.thymeleaf.org" 会有语法提示-->
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:easyui="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
    <title>菜单管理</title>
    <script type="text/javascript" src="../../static/easyui/boot.js" th:src="@{/static/easyui/boot.js}"></script>
</head>
<body class="easyui-layout">
    <div id="tb" style="padding:10px;height:auto">
        <easyui:button label="新增" vtype="add" name="butAdd" onclick="add()"/>
        <easyui:button label="编辑" vtype="edit" name="butEdit" onclick="edit()"/>
        <easyui:button label="删除" vtype="del" name="butDel"/>
    </div>
<table id="treegrList" class="easyui-treegrid" style="width:100%;height:100%" animate="true" checkbox="false" rownumbers="true"
       url="/sysMenu/getMenuTreeList.do" multiple="false"
       toolbar="#tb" fitcolumns="true" idField="id" treeField="name">
        <thead>
            <tr align="center">
                <th field="id" resizable="true" halign="center" width="10" align="center" sortable="false" hidden="hidden">ID</th>
                <th field="pid" resizable="true" halign="center" width="10" align="center" sortable="false" hidden="hidden">pId</th>
                <th field="name" resizable="true" halign="center" width="100" align="center" sortable="false">菜单名称</th>
                <th field="iconCls" resizable="true" halign="center" width="100" align="center" sortable="false">图标</th>
                <th field="menuUrl" resizable="true" halign="center" width="100" align="center" sortable="false">地址</th>
                <th field="createTime" resizable="true" halign="center" width="100" align="center" sortable="false" >创建时间</th>
            </tr>
        </thead>
    </table>
    </body>
    </html>
<script type="text/javascript">
    $(document).ready(function () {
        // $('#treegrList').treegrid({
        //     onLoadSuccess: function(){
        //         $('#treegrList').treegrid("collapseAll");
        //     }
        // });

    });
    //添加
    function add(){
        windowsOpen("新增菜单","/sysMenu/edit.do?id=0",900,500,function(){
            $('#dg').datagrid('reload');
        });
    }

    //编辑
    function edit(){
        var data = $("#treegrList").datagrid("getSelected");
        if(data){
            windowsOpen("编辑菜单","/sysMenu/edit.do?id="+data.id,900,500,function(){
                $('#treegrList').datagrid('reload');
            });
        }else{
            showAlert("提示","请勾选一条数据后再操作!");
        }
    }

</script>